home *** CD-ROM | disk | FTP | other *** search
- /******** System includes ********/
- #include <Quickdraw.h>
- #include <ControlMgr.h>
- #include <MemoryMgr.h>
- #include <OSUtil.h>
- #include <WindowMgr.h>
- #include <EventMgr.h>
- /**********************************/
-
- /******** typedefs ********/
- typedef struct {
- char *cdef_ptr ;
- } CJMP, *CJMP_PTR, **CJMP_HDL ;
- /**********************************/
-
- /******** defines ********/
- #define NULL 0L
- /**********************************/
-
- /******** prototypes ********/
- extern pascal long _main( ) ;
- void main( void ) ;
- void TestControl( void ) ;
- /**********************************/
-
- /******** globals ********/
- CJMP_HDL cjmp_hdl ;
- Rect test_window_rect = { 40, 10, 300, 400 } ;
- Rect test_control_rect = { 10, 10, 34, 150 } ;
- /**********************************/
-
- void main( )
- {
- /* Initialize the macintosh managers */
- InitGraf( ( Ptr) &thePort ) ;
- InitFonts( ) ;
- InitWindows( ) ;
- InitCursor( ) ;
- InitMenus( ) ;
- TEInit( ) ;
- InitDialogs( 0L ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- MoreMasters( ) ;
- FlushEvents( everyEvent, 0 ) ;
-
- if( ( cjmp_hdl = (CJMP_HDL)GetResource( 'CJMP', 9999 ) ) == 0L ) {
- /* First create CJMP structure */
- cjmp_hdl = (CJMP_HDL)NewHandle( sizeof( CJMP ) ) ;
-
- /* Now make it into a resource so that the dummy cdef can access it */
- AddResource( cjmp_hdl, 'CJMP', 9999, "\pcdef jump structure" ) ;
- }
- (**cjmp_hdl).cdef_ptr = (char *)_main ;
-
- /* Now call test control routine */
- TestControl( ) ;
-
- /* Now remove the resource */
- RmveResource( cjmp_hdl ) ;
-
- return ;
- }
- void TestControl( )
- {
- WindowPtr window_ptr ;
- ControlHandle control_hdl ;
- ControlHandle control_hdl2 ;
- long tmp ;
- EventRecord event ;
- Point pt ;
- int part_code ;
- int last_part_code ;
- ControlHandle which_control ;
-
- /* Open the window */
- window_ptr = NewWindow( NULL, &test_window_rect, "\ptest window", TRUE, 1,
- (WindowPtr)-1L, FALSE, 0L ) ;
-
- if( window_ptr == NULL ) return ;
-
- SetPort( window_ptr ) ;
-
- /* Open the control */
- control_hdl = NewControl( window_ptr, &test_control_rect, "\ptest control",
- TRUE, 0, 0, 0, 32, 0L ) ;
- OffsetRect( &test_control_rect, 150, 50 ) ;
- control_hdl2 = NewControl( window_ptr, &test_control_rect, "\ptest control",
- TRUE, 0, 0, 0, 32, 0L ) ;
-
- /* Now start miniature event loop */
- while( TRUE ) {
-
- GetNextEvent( everyEvent, &event ) ;
-
- pt = event.where ;
-
- SetPort( window_ptr ) ;
-
- GlobalToLocal( &pt ) ;
-
- if( event.what == mouseDown ) {
-
- part_code = FindControl( pt, window_ptr, &which_control ) ;
-
- if( which_control == NULL ) {
- if( (**control_hdl).contrlHilite != 0 ) {
- HiliteControl( control_hdl, 0 ) ;
- }
- if( (**control_hdl2).contrlHilite != 0 ) {
- HiliteControl( control_hdl2, 0 ) ;
- }
- SysBeep( 5 ) ;
- }else{
- part_code = TrackControl( which_control, pt, (ProcPtr)-1L ) ;
- HiliteControl( which_control, part_code ) ;
- if( which_control == control_hdl ) {
- if( (**control_hdl2).contrlHilite != 0 ) {
- HiliteControl( control_hdl2, 0 ) ;
- }
- }
- if( which_control == control_hdl2 ) {
- if( (**control_hdl).contrlHilite != 0 ) {
- HiliteControl( control_hdl, 0 ) ;
- }
- }
- }
- }
- if( event.what == keyDown ) {
- break ;
- }
- }
-
- /* Close the control */
- DisposeControl( control_hdl ) ;
- DisposeControl( control_hdl2 ) ;
-
- /* Close the window */
- DisposeWindow( window_ptr ) ;
- return ;
- }
-